home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: Newbie needs help w/ARGV ARGC
- Date: Tue, 26 Mar 1996 14:57:07 -0800
- Organization: systems hk
- Message-ID: <31587643.6355@teleport.com>
- References: <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>
- NNTP-Posting-Host: ip-pdx02-38.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (WinNT; I)
-
- Raymond Joh wrote:
- > I just want to be able to enter two file paths at the command line.
- > Here is my code:
- > #include <stdio.h>
- > #include <stdlib.h>
- >
- > main(int argc, char *argv[],char *envp[])
- > {
- > FILE *ofp,*nfp;
- > char ch;
- >
- > gets(*argv);
- >
- > if (argc!=3)
- > {
- > printf("Enter: <source> <destination>\n");
- > exit(1);
- > }
- > Code countinues but when I enter my command line input such as:
- > A:\readme.txt A:\newfile.txtRaymond,
- You do not 'gets' the command-line arguments; you are given an
- array of pointers to strings, so treat them as a list of char
- strings:
-
- ...
- if( argc >= 3 ) {
- strcpy( file1,argv[1] );
- strcpy( file2,argv[2] );
- ...
- Yours, Geoff Houck
-